import React, {
  Component,
  memo,
  useState,
  useMemo,
  useCallback,
  useEffect,
} from 'react';
//自定义HOOKS
import { useSetPageTitle } from './title';

import { Button } from 'antd';
import { useLunxun } from './mylunxun';
class SystemManage extends Component {
  render() {
    return (
      <div>
        分行管理
        <Parent></Parent>
      </div>
    );
  }
}
//性能优化   useMemo
function Parent() {
  const [count, setcount] = useState(1);
  const [countChild, setcountChild] = useState(2);
  const { string, startAxiosLong } = useLunxun();
  //自定义
  const [title, setTitle] = useSetPageTitle('我是标题');
  // startAxiosLong();
  const childC = useMemo(() => {
    return { countChild };
  }, [countChild]);
  return (
    <>
      {string}
      <Child count={childC}></Child>
      <br />
      count:{count}
      <br />
      countChild:{countChild}
      <br />
      <div className="title">文章标题： {title}</div>
      <Button
        onClick={() => {
          setcount(count + 1);
        }}
      >
        +1
      </Button>
      <Button
        onClick={() => {
          setcountChild(countChild + 1);
        }}
      >
        +1
      </Button>
      <input onChange={(e) => setTitle(e.target.value)}></input>
    </>
  );
}
const Child = memo((props) => {
  const date = new Date();
  console.log(props);

  return (
    <>
      当前时间:{date.getHours()} : {date.getMinutes()} : {date.getSeconds()}
    </>
  );
});

export default SystemManage;
